package com.gin.retrofit.utils

import com.gin.retrofit.interceptor.CollectionParameterInterceptor
import com.gin.retrofit.interceptor.StaticFieldInterceptor
import com.gin.retrofit.interceptor.StaticQueryInterceptor
import okhttp3.OkHttpClient
import java.util.concurrent.TimeUnit

/**
 * @author BX-Gin
 * @since 2024/3/9 17:18
 */
class OkhttpUtils {
    companion object {
        /**
         * 创建OkHttpClient实例
         * @return OkHttpClient
         */
        @JvmStatic
        fun obtainOkHttpClient(): OkHttpClient {
            return OkHttpClient.Builder()
                .addInterceptor(StaticQueryInterceptor())
                .addInterceptor(StaticFieldInterceptor())
                .addInterceptor(CollectionParameterInterceptor())
                .callTimeout(30, TimeUnit.SECONDS)
                .connectTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .build()
        }
    }
}